home *** CD-ROM | disk | FTP | other *** search
/ ADA Programming Guide / ADA Programming Guide.iso / ada_gwu / ipredef.h < prev    next >
C/C++ Source or Header  |  1996-01-30  |  4KB  |  155 lines

  1. /*
  2.  * Copyright (C) 1985-1992  New York University
  3.  * 
  4.  * This file is part of the Ada/Ed-C system.  See the Ada/Ed README file for
  5.  * warranty (none) and distribution info and also the GNU General Public
  6.  * License for more details.
  7.  
  8.  */
  9. /*    +---------------------------------------------------+
  10.       |                           |
  11.       |      I N T E R P     P R E D E F S          |
  12.       |                           |
  13.       |          D E F I N I T I O N S          |
  14.       |                           |
  15.       |           (C Version)              |
  16.       |                           |
  17.       |   Adapted From Low Level SETL version written by  |
  18.       |                           |
  19.       |          Monte Zweben              |
  20.       |           Philippe Kruchten           |
  21.       |           Jean-Pierre Rosen           |
  22.       |                           |
  23.       |    Original High Level SETL version written by      |
  24.       |                           |
  25.       |           Clint Goss              |
  26.       |           Tracey M. Siesser           |
  27.       |           Bernard D. Banner           |
  28.       |           Stephen C. Bryant           |
  29.       |          Gerry Fisher              |
  30.       |                           |
  31.       |          C version written by          |
  32.       |                           |
  33.       |           Robert B. K. Dewar          |
  34.       |                           |
  35.       +---------------------------------------------------+
  36. */
  37.  
  38.  
  39. /* Constants For PRDEF Operations */
  40.  
  41. #include <stdlib.h>
  42. #include <stdio.h>
  43. #include "config.h"
  44. #include "int.h"
  45. #include "predef.h"
  46. #include "ivars.h"
  47.  
  48. /* ASCII control characters */
  49.  
  50. #define  BS   0x08
  51. #define  HT   0x09
  52. #define  LF   0x0a
  53. #define  FF   0x0c
  54. #define  CR   0x0d
  55.  
  56. /* ASCII quote character */
  57.  
  58. #define QUOTE 0x27
  59.  
  60. /* Codes used in io_mode field of AFCB */
  61.  
  62. #define SIO_IN_FILE    0    /* SEQUENTIAL_IO IN  */
  63. #define SIO_OUT_FILE   1    /* SEQUENTIAL_IO OUT */
  64.  
  65. #define DIO_IN_FILE    0    /* DIRECT_IO IN    */
  66. #define DIO_INOUT_FILE 1    /* DIRECT_IO INOUT */
  67. #define DIO_OUT_FILE   2    /* DIRECT_IO OUT   */
  68.  
  69. #define TIO_IN_FILE    0    /* TEXT_IO IN  */
  70. #define TIO_OUT_FILE   1    /* TEXT_IO OUT */
  71.  
  72. /* Utility macros to access attributes of current file */
  73.  
  74. #define IOFDESC        (afcbs[filenum-1]->io_fdesc)
  75. #define IOFNAME        (afcbs[filenum-1]->io_fname)
  76. #define IOFORM           (afcbs[filenum-1]->io_form)
  77. #define IOMODE           (afcbs[filenum-1]->io_mode)
  78. #define DPOS           (afcbs[filenum-1]->dio_pos)
  79. #define DSIZE           (afcbs[filenum-1]->dio_size)
  80. #define DLENGTH        (afcbs[filenum-1]->dio_length)
  81. #define PAGE           (afcbs[filenum-1]->tio_page)
  82. #define LINE           (afcbs[filenum-1]->tio_line)
  83. #define COL           (afcbs[filenum-1]->tio_col)
  84. #define LINE_LENGTH       (afcbs[filenum-1]->tio_line_length)
  85. #define PAGE_LENGTH       (afcbs[filenum-1]->tio_page_length)
  86. #define CHARS           (afcbs[filenum-1]->tio_count)
  87. #define CHAR1           (afcbs[filenum-1]->tio_look_ahead[0])
  88. #define CHAR2           (afcbs[filenum-1]->tio_look_ahead[1])
  89. #define CHAR3           (afcbs[filenum-1]->tio_look_ahead[2])
  90.  
  91. /* Macros testing file attributes */
  92.  
  93. #define BOUNDED_LINE_LENGTH    (LINE_LENGTH > 0)
  94. #define UNBOUNDED_LINE_LENGTH  (LINE_LENGTH == 0)
  95. #define BOUNDED_PAGE_LENGTH    (PAGE_LENGTH > 0)
  96. #define UNBOUNDED_PAGE_LENGTH  (PAGE_LENGTH == 0)
  97. #define PAGE_TERMINATED (COL == 1 && LINE == 1 && PAGE != 1)
  98.  
  99. /* Maximum identifier length */
  100.  
  101. #define  MAX_ID        80
  102.  
  103. /* Define special characters in text file */
  104.  
  105. #define PAGE_MARK  0x0C            /* page terminator */
  106. #define LINE_FEED  0x0a            /* line terminator */
  107.  
  108. /* Convert character to upper case */
  109.  
  110. #define UPPER_CASE(x) (('a' <= (x) && (x) <= 'z') ? (x - 32) : x)
  111.  
  112. /* Forward definitions for value returning functions */
  113.  
  114. int scan_integer();
  115. int scan_integer_string();
  116. long scan_fixed();
  117. long scan_fixed_string();
  118. float scan_float();
  119. float scan_float_string();
  120. int get_argument_value();
  121. float get_float_argument_value();
  122. long get_long_argument_value();
  123. int *get_argument_ptr();
  124.  
  125. char get_char();
  126. char *make_string();
  127. char *predef_alloc();
  128.  
  129. /* On the PC, need to distinguish binary and text files, so use
  130.  * fopen_bin and fopen_txt, respectively. On other machines, this
  131.  * distinction need not be made, so fopen_bin and fopen_txt are
  132.  * macros.
  133.  */
  134. #ifdef IBM_PC
  135. FILE *fopen_bin();
  136. FILE *fopen_txt();
  137. #else
  138. #define fopen_bin(a,b) fopen(a,b)
  139. #define fopen_txt(a,b) fopen(a,b)
  140. #endif
  141.  
  142. #define COUNT_LAST 32767
  143. #define LOWER_CASE 0
  144.  
  145. #define DISCARD_GENERIC_PARAMETER cur_stackptr -= 2
  146.  
  147. /* if DEBUG_PREDEF defined, get detailed trace on IO operations
  148.  * using pchar and gchar; these are made into null macros if
  149.  * the trace is not desired.
  150.  */
  151. #ifndef DEBUG_PREDEF
  152. #define pchar(a,b)
  153. #define gchar(a,b)
  154. #endif
  155.